.TH std::numpunct_byname 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::numpunct_byname \- std::numpunct_byname

.SH Synopsis
   Defined in header <locale>
   template< class CharT >
   class numpunct_byname : public std::numpunct<CharT>;

   std::numpunct_byname is a std::numpunct facet which encapsulates numeric punctuation
   preferences of a locale specified at its construction.

.SH Specializations

   The standard library is guaranteed to provide the following specializations:

   Defined in header <locale>
   std::numpunct_byname<char>    locale-specific std::numpunct facet for narrow
                                 character I/O
   std::numpunct_byname<wchar_t> locale-specific std::numpunct facet for wide character
                                 I/O

.SH Member types

   Member type Definition
   char_type   CharT
   string_type std::basic_string<CharT>

.SH Member functions

   constructor   constructs a new numpunct_byname facet
                 \fI(public member function)\fP
   destructor    destroys a numpunct_byname facet
                 \fI(protected member function)\fP



std::numpunct_byname::numpunct_byname

   explicit numpunct_byname( const char* name, std::size_t refs = 0 );
   explicit numpunct_byname( const std::string& name, std::size_t refs =  \fI(since C++11)\fP
   0 );

   Constructs a new std::numpunct_byname facet for a locale with name.

   refs is used for resource management: if refs == 0, the implementation destroys the
   facet, when the last std::locale object holding it is destroyed. Otherwise, the
   object is not destroyed.

.SH Parameters

   name - the name of the locale
   refs - the number of references that link to the facet



std::numpunct_byname::~numpunct_byname

   protected:
   ~numpunct_byname();

   Destroys the facet.



Inherited from std::numpunct

.SH Member types

   Member type Definition
   char_type   CharT
   string_type std::basic_string<CharT>

.SH Member functions

   decimal_point invokes do_decimal_point
                 \fI(public member function of std::numpunct<CharT>)\fP
   thousands_sep invokes do_thousands_sep
                 \fI(public member function of std::numpunct<CharT>)\fP
   grouping      invokes do_grouping
                 \fI(public member function of std::numpunct<CharT>)\fP
   truename      invokes do_truename or do_falsename
   falsename     \fI(public member function of std::numpunct<CharT>)\fP

.SH Protected member functions

   do_decimal_point provides the character to use as decimal point
   \fB[virtual]\fP        \fI(virtual protected member function of std::numpunct<CharT>)\fP
   do_thousands_sep provides the character to use as thousands separator
   \fB[virtual]\fP        \fI(virtual protected member function of std::numpunct<CharT>)\fP
   do_grouping      provides the numbers of digits between each pair of thousands
   \fB[virtual]\fP        separators
                    \fI(virtual protected member function of std::numpunct<CharT>)\fP
   do_truename      provides the string to use as the name of the boolean true and
   do_falsename     false
   \fB[virtual]\fP        \fI(virtual protected member function of std::numpunct<CharT>)\fP

.SH Member objects

   static std::locale::id id id of the locale
                             \fI(public member object)\fP

.SH Example

   This example demonstrates how to apply numeric punctuation rules of another language
   without changing the rest of the locale.


// Run this code

 #include <iostream>
 #include <locale>

 int main()
 {
     const double number = 1000.25;
     std::wcout << L"default locale: " << number << L'\\n';
     std::wcout.imbue(std::locale(std::wcout.getloc(),
                                  new std::numpunct_byname<wchar_t>("ru_RU.UTF8")));
     std::wcout << L"default locale with russian numpunct: " << number << L'\\n';
 }

.SH Output:

 default locale: 1000.25
 default locale with russian numpunct: 1 000,25

.SH See also

   numpunct defines numeric punctuation rules
            \fI(class template)\fP
